package Algorithm.DoublePointer;
// https://leetcode-cn.com/problems/sort-array-by-parity/
public class Leetcode905_按奇偶排序数组 {
    class Solution {
        public int[] sortArrayByParity(int[] nums) {
            int n = nums.length;
            int[] res = new int[n];
            int left = 0, right = n - 1;
            for (int num : nums) {
                if (num % 2 == 0) {
                    res[left++] = num;
                } else {
                    res[right--] = num;
                }
            }
            return res;
        }
    }
}

